/**
 * Copyright (C) 2024-2030 Super BilGen & 超亿时代信息技术股份有限公司.All Rights Reserved.
 */
package cn.com.yang.ruleengine;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.Expression;

/**
 * @Model cn.com.yang.ruleengine.AviatorVariableExample
 * @Desc  规则引擎：aviator
 * @author yangyijin
 * @since 2025年4月18日-上午8:51:11
 */
public class AviatorVariableExample {
	
	@Test
	public void aviator() {
		Map<String,Object> obj = new HashMap<String,Object>();
		obj.put("a", 10);
		obj.put("b", 20);
		Long result =(Long) AviatorEvaluator.execute("a + b", obj);
		System.out.println(result);
		
		result = (Long) AviatorEvaluator.execute("math.round(3.14)");
		System.out.println(result);
		
//		String strResult = (String) AviatorEvaluator.execute("String.toUpperCase('hello')");
//		System.out.println(strResult);
		
		Expression expression = AviatorEvaluator.compile("2*(3+5)");
		result=(Long)expression.execute();
		System.out.println(result);
	}
}
